<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>列表操作日志记录</title>
    <meta name="keywords" content="列表操作日志记录">
    <meta name="description" content="列表操作日志记录">
    <link rel="shortcut icon" href="/web/favicon.ico">
    <link href="/web/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="/web/css/font-awesome.min.css" rel="stylesheet"/>
    <!-- bootstrap-table 表格插件样式 -->
    <link href="/web/ajax/libs/bootstrap-table/bootstrap-table.min.css?v=20210202" rel="stylesheet"/>
    <link href="/web/css/animate.min.css" rel="stylesheet"/>
    <link href="/web/css/style.css?v=20200903" rel="stylesheet"/>
    <link href="/web/andy/css/ry-ui.css?v=4.6.1" rel="stylesheet"/>
    <a id="scroll-up" href="javascript:void(0);" class="btn btn-sm display"><i class="fa fa-angle-double-up"></i></a>
    <script src="/web/js/jquery.min.js"></script>
    <script src="/web/js/bootstrap.min.js"></script>
    <!-- bootstrap-table 表格插件 -->
    <script src="/web/ajax/libs/bootstrap-table/bootstrap-table.min.js"></script>
    <script src="/web/ajax/libs/bootstrap-table/locale/bootstrap-table-zh-CN.min.js?v=20210202"></script>
    <script src="/web/ajax/libs/bootstrap-table/extensions/mobile/bootstrap-table-mobile.js"></script>
    <!-- jquery-validate 表单验证插件 -->
    <script src="/web/ajax/libs/validate/jquery.validate.min.js"></script>
    <script src="/web/ajax/libs/validate/messages_zh.min.js"></script>
    <script src="/web/ajax/libs/validate/jquery.validate.extend.js"></script>
    <!-- 遮罩层 -->
    <script src="/web/ajax/libs/blockUI/jquery.blockUI.js"></script>
    <script src="/web/ajax/libs/iCheck/icheck.min.js"></script>
    <script src="/web/ajax/libs/layer/layer.min.js"></script>
    <script src="/web/ajax/libs/layui/layui.js"></script>
    <script src="/web/andy/js/common.js?v=4.6.1"></script>
    <script src="/web/andy/js/andy-ui.js?v=4.6.1"></script>
    <script src="/webjars/vue/2.6.14/vue.min.js"></script>
</head>
<body class="gray-bg">
<div id="container">
    <div class="container-div" >
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="query">
                    <div class="select-list">
                        <ul>
                            <li>
                                菜单名称：<input type="text" name="menuName" value="" v-model="param.menuName"/>
                            </li>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" @click="add();">
                    <i class="fa fa-plus"></i> 新增
                </a>
                <a class="btn btn-primary" @click="edit();">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-warning" @click="deletes();">
                    <i class="glyphicon glyphicon-trash" aria-hidden="true"></i>删除
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>

    <div class="wrapper wrapper-content animated fadeInRight ibox-content" id="addForm" style="display: none">
        <form class="form-horizontal m" id="form-menu-add">
                        <input type="hidden" v-model="entity.operId"/>

                            <div class="form-group">
                                <label class="control-label col-sm-3">
                                    模块标题
                                </label>
                                <div class="col-sm-7" >
                                    <input v-model="entity.title" type="text"  class="form-control" name="title"  placeholder="模块标题">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="control-label col-sm-3">
                                    业务类型（0其它 1新增 2修改 3删除）
                                </label>
                                <div class="col-sm-7" >
                                    <input v-model="entity.businessType" type="text"  class="form-control" name="businessType"  placeholder="业务类型（0其它 1新增 2修改 3删除）">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="control-label col-sm-3">
                                    方法名称
                                </label>
                                <div class="col-sm-7" >
                                    <input v-model="entity.method" type="text"  class="form-control" name="method"  placeholder="方法名称">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="control-label col-sm-3">
                                    请求方式
                                </label>
                                <div class="col-sm-7" >
                                    <input v-model="entity.requestMethod" type="text"  class="form-control" name="requestMethod"  placeholder="请求方式">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="control-label col-sm-3">
                                    操作类别（0其它 1后台用户 2手机端用户）
                                </label>
                                <div class="col-sm-7" >
                                    <input v-model="entity.operatorType" type="text"  class="form-control" name="operatorType"  placeholder="操作类别（0其它 1后台用户 2手机端用户）">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="control-label col-sm-3">
                                    操作人员
                                </label>
                                <div class="col-sm-7" >
                                    <input v-model="entity.operName" type="text"  class="form-control" name="operName"  placeholder="操作人员">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="control-label col-sm-3">
                                    部门名称
                                </label>
                                <div class="col-sm-7" >
                                    <input v-model="entity.deptName" type="text"  class="form-control" name="deptName"  placeholder="部门名称">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="control-label col-sm-3">
                                    请求URL
                                </label>
                                <div class="col-sm-7" >
                                    <input v-model="entity.operUrl" type="text"  class="form-control" name="operUrl"  placeholder="请求URL">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="control-label col-sm-3">
                                    主机地址
                                </label>
                                <div class="col-sm-7" >
                                    <input v-model="entity.operIp" type="text"  class="form-control" name="operIp"  placeholder="主机地址">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="control-label col-sm-3">
                                    操作地点
                                </label>
                                <div class="col-sm-7" >
                                    <input v-model="entity.operLocation" type="text"  class="form-control" name="operLocation"  placeholder="操作地点">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="control-label col-sm-3">
                                    请求参数
                                </label>
                                <div class="col-sm-7" >
                                    <input v-model="entity.operParam" type="text"  class="form-control" name="operParam"  placeholder="请求参数">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="control-label col-sm-3">
                                    返回参数
                                </label>
                                <div class="col-sm-7" >
                                    <input v-model="entity.jsonResult" type="text"  class="form-control" name="jsonResult"  placeholder="返回参数">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="control-label col-sm-3">
                                    操作状态（0正常 1异常）
                                </label>
                                <div class="col-sm-7" >
                                    <input v-model="entity.status" type="text"  class="form-control" name="status"  placeholder="操作状态（0正常 1异常）">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="control-label col-sm-3">
                                    错误消息
                                </label>
                                <div class="col-sm-7" >
                                    <input v-model="entity.errorMsg" type="text"  class="form-control" name="errorMsg"  placeholder="错误消息">
                                </div>
                            </div>


            </form>
    </div>
</div>
</body>
<script>
    let vm = new Vue({
        el:'#container',
        data:{
            datas:[],
            param:{
                visible:'',
            },
            entity:{}
        },
        methods:{
            edit:function(){
                let rows = $("#bootstrap-table").bootstrapTable('getSelections');
                if ($.common.isEmpty(rows) || rows.length>1) {
                    $.modal.alertWarning("请最多选择一条记录");
                    return;
                }
                $.operate.getNoAlert('/system/operLog/info/'+rows[0].roleId,function(ret){
                    let data = ret.data;
                    vm.entity=data;
                    alert(JSON.stringify(vm.entity))
                    $.operate.edit(0,'addForm',doSubmit);
                });

            },
            add:function(){
                vm.entity={};
                $.operate.edit(0,'addForm',doSubmit);
            }
        },
        mounted(){
            init();
        }
    });

    function edit_(id){
        $.operate.getNoAlert('/system/operLog/'+id,function(ret){
            let obj = ret.data;
            vm.entity=obj;
            $.operate.edit(0,'addForm',doSubmit);
        });

    }
    function deleteById(id){
        layer.confirm("确定删除当前菜单吗？",function(){
            $.operate.delete('/system/operLog/delete/'+id);
        });
    }
    function deletes(){

        let rows = $("#bootstrap-table").bootstrapTable('getSelections');
        if ($.common.isEmpty(rows) || rows.length<1) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }
        let ids=new Array();
        for(let i=0;i<rows.length;i++){
            ids.push(rows[i].roleId);
        }
        $.operate.deletes('/system/operLog/delete',{"ids":ids});
    }
    function init(){
        var addFlag = false;
        addFlag=true;
        var editFlag = false;
        addFlag=true;
        var removeFlag = false;
        addFlag=true;
        var datas =[];
        var prefix =  "/system/role";
        let options={
            url:'/system/operLog/data',
            sortable:false,
            columns:[
                {
                    checkbox : true,
                    align : 'center'
                },
                    {
                        field:'operId',
                        title:'日志主键',
                        align: 'center',
                        halign: 'center',
                        visible: false,
                        sortable:true
                    },
                    {
                        field:'title',
                        title:'模块标题',
                        align: 'center',
                        halign: 'center',
                        sortable:true
                    },
                    {
                        field:'businessType',
                        title:'业务类型',
                        align: 'center',
                        halign: 'center',
                        sortable:true,
                        formatter:function(value,row,index){
                            if(row.businessType=='0') return '其他';
                            if(row.businessType=='1') return '新增';
                            if(row.businessType=='2') return '修改';
                            if(row.businessType=='3') return '删除';
                         }
                    },
                    {
                        field:'method',
                        title:'方法名称',
                        align: 'center',
                        halign: 'center',
                        sortable:true,
                        formatter:function(value,row,index){
                            return value.substring(value.lastIndexOf(".")+1,value.length);
                        }
                    },
                    {
                        field:'requestMethod',
                        title:'请求方式',
                        align: 'center',
                        halign: 'center',
                        sortable:true
                    },
                    {
                        field:'operatorType',
                        title:'操作类别',
                        align: 'center',
                        halign: 'center',
                        sortable:true,
                        visible:false,
                        formatter:function(value,row,index){
                            if(row.operatorType=='0') return '其他';
                            if(row.operatorType=='1') return '后台用户';
                            if(row.operatorType=='2') return '手机端用户';
                        }
                    },
                    {
                        field:'operName',
                        title:'操作人员',
                        align: 'center',
                        halign: 'center',
                        sortable:true
                    },
                    {
                        field:'deptName',
                        title:'部门名称',
                        align: 'center',
                        halign: 'center',
                        sortable:true
                    },
                    {
                        field:'operUrl',
                        title:'请求URL',
                        align: 'center',
                        halign: 'center',
                        sortable:true
                    },
                    {
                        field:'operIp',
                        title:'主机地址',
                        align: 'center',
                        halign: 'center',
                            visible: false,
                        sortable:true
                    },
                    {
                        field:'operLocation',
                        title:'操作地点',
                        align: 'center',
                        halign: 'center',
                            visible: false,
                        sortable:true
                    },
                    {
                        field:'operParam',
                        title:'请求参数',
                        align: 'center',
                        halign: 'center',
                        sortable:true
                    },
                    {
                        field:'jsonResult',
                        title:'返回参数',
                        align: 'center',
                        halign: 'center',
                            visible: false,
                        sortable:true
                    },
                    {
                        field:'status',
                        title:'操作状态',
                        align: 'center',
                        halign: 'center',
                        sortable:true,
                        formatter:function(value,row,index){
                            if(value==0){
                                return "<span class=\"label label-info\">正常</span>";
                            }
                            return "<span class=\"label label-warning\">男</span>";
                        }
                    },
                    {
                        field:'errorMsg',
                        title:'错误消息',
                        align: 'center',
                        halign: 'center',
                            visible: false,
                        sortable:true
                    },
                    {
                        field:'operTime',
                        title:'操作时间',
                        align: 'center',
                        halign: 'center',
                        sortable:true,
                        formatter:function(value,row,index){
                           return dateFormat("YYYY-mm-dd HH:MM:SS",new Date(value));
                        }
                    },
                {
                    title:'操作',
                    width:100,
                    align: 'center',
                    halign: 'center',
                    formatter:function (value,row,index){
                        let actions=[];
                        actions.push("<a href='javascript:void(0)' onclick=\"edit('编辑操作日志记录','container','"+row.operId+"')\" title=\"点击编辑操作日志记录\"><i class=\"glyphicon glyphicon-edit\" aria-hidden=\"true\"></i></a>&nbsp;&nbsp;");
                        actions.push("<a href='javascript:void(0)' title='点击删除操作日志记录' onclick=\"deleteById('"+row.operId+"')\"><i class=\"glyphicon glyphicon-trash\" aria-hidden=\"true\"></i></a>&nbsp;&nbsp;");

                        return actions.join("");
                    }
                }
            ]
        }
        $.table.init(options);
    }


    function doSubmit(){
        if($("#form-menu-add").valid()){
            $.operate.post("/system/role/save",JSON.stringify(vm.entity),function(ret){
                layer.closeAll();
            });
        }
    }
</script>

<script>
    $(function(){
        var icon = "<i class='fa fa-times-circle'></i> ";
        formValidate = $("#form-menu-add").validate({
            rules:{
                operId: "required" , 
                title: "required" , 
                businessType: "required" , 
                method: "required" , 
                requestMethod: "required" , 
                operatorType: "required" , 
                operName: "required" , 
                deptName: "required" , 
                operUrl: "required" , 
                operIp: "required" , 
                operLocation: "required" , 
                operParam: "required" , 
                jsonResult: "required" , 
                status: "required" , 
                errorMsg: "required" , 
                operTime: "required" 
            },
            messages:{
                operId: icon + "必填" , 
                title: icon + "必填" , 
                businessType: icon + "必填" , 
                method: icon + "必填" , 
                requestMethod: icon + "必填" , 
                operatorType: icon + "必填" , 
                operName: icon + "必填" , 
                deptName: icon + "必填" , 
                operUrl: icon + "必填" , 
                operIp: icon + "必填" , 
                operLocation: icon + "必填" , 
                operParam: icon + "必填" , 
                jsonResult: icon + "必填" , 
                status: icon + "必填" , 
                errorMsg: icon + "必填" , 
                operTime: icon + "必填" 
            }
        })
    })
</script>

<script>

</script>
</html>
